#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10,A=1e6+10;
int n,a[N];
int g[N];
int f[2];
int ans;
void dfs(int u) {
    if(u==n+1) {
        f[0]=f[1]=0;
        int cnt=0;
        for(int i=1;i<=n;i++) {
            if(a[f[g[i]]]==a[i])cnt+=a[i];
            f[g[i]]=i;
        }
        ans=max(ans,cnt);
        return;
    }
    dfs(u+1);
    g[u]=1;
    dfs(u+1);
    g[u]=0;
    return;
}
void solve() {
    ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    dfs(1);
    cout<<ans<<endl;
    return;
}
signed main() {
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
/*

*/
